package com.google.code.cisx.client.gadgets;

import com.google.code.cisx.client.model.Gadget;
import com.google.code.cisx.client.model.GadgetClass;
import com.google.code.cisx.client.model.UserPref;
import com.google.gwt.user.client.ui.Label;

public class HelloWorldGadget extends Gadget {

  public static class Class extends GadgetClass {
    public static UserPref text = new UserPref("Text", "Hello World");

    public Class() {
      super("HelloWorld", true);
      addUserPref(text);
    }

    public Gadget newGadget() {
      return new HelloWorldGadget(this);
    }
  }

  private Label label = new Label();

  protected HelloWorldGadget(Class c) {
    super(c);
    initWidget(label);
    setStyleName("HelloWorld");
  }

  public void refresh() {
    label.setText((String) getUserPrefValue(Class.text));
  }
}